/**
 * Created with JetBrains PhpStorm.
 * User: Nishchit Dhanani
 * Date: 26/4/14
 * Time: 11:46 AM
 * To change this template use File | Settings | File Templates.
 */


'use strict';
var jwellery;
jwellery = angular.module("jwellery", ['ui.router', 'ngRoute', 'mgcrea.ngStrap','category'])

        .config(function($stateProvider, $routeProvider, $httpProvider, $urlRouterProvider) {

            //$httpProvider.interceptors.push('httpInterceptor');
            $stateProvider
                    .state('dashboard', {
                        url: "/dashboard",
                        templateUrl: "app/partials/dashboard.html",
                        //controller: "DashboardCtrl"
                    })
                    .state('category', {
                        url: "/category",
                        templateUrl: "app/partials/category.html",
                        controller: "CategoryCtrl"
                    })
                    
            $urlRouterProvider.otherwise('/dashboard');

        });

jwellery.run(
        function($rootScope, $state, $location, $window) {


        });

jwellery.controller('AppCtrl', function($scope, $state, $stateParams, $timeout) { // Include service

    // To set state and its parameters
    $scope.goTo = function(state, params) {
        $timeout(function() {
            if (params) {
                $state.transitionTo(state, params);
            } else {
                $state.transitionTo(state, $stateParams);
            }
        }, 500);
    }
    
    // Dob validation (disable dates >= Current date)
    var d = moment().add('day', -1);
    $scope.dobMaxDate = moment(d)._d;
    
    // Notification
    $scope.setSuccessFlash = function(text) {

        toastr.options = {
            "closeButton": false,
            "debug": false,
            "positionClass": "toast-bottom-right",
            "onclick": null,
            "showDuration": "300",
            "hideDuration": "1000",
            "timeOut": "0",
            "extendedTimeOut": "0",
            "showEasing": "swing",
            "hideEasing": "linear",
            "showMethod": "fadeIn",
            "hideMethod": "fadeOut"
        };

        toastr.success(text);
    };
    $scope.setWarningFlash = function(text) {

        toastr.options = {
            "closeButton": false,
            "debug": false,
            "positionClass": "toast-bottom-right",
            "onclick": null,
            "showDuration": "300",
            "hideDuration": "1000",
            "timeOut": "0",
            "extendedTimeOut": "0",
            "showEasing": "swing",
            "hideEasing": "linear",
            "showMethod": "fadeIn",
            "hideMethod": "fadeOut"
        };

        toastr.warning(text);

    };
    $scope.setErrorFlash = function(text) {

        toastr.options = {
            "closeButton": false,
            "debug": false,
            "positionClass": "toast-bottom-right",
            "onclick": null,
            "showDuration": "300",
            "hideDuration": "1000",
            "timeOut": "0",
            "extendedTimeOut": "0",
            "showEasing": "swing",
            "hideEasing": "linear",
            "showMethod": "fadeIn",
            "hideMethod": "fadeOut"
        }

        toastr.error(text);

    };
    $scope.setInfoFlash = function(text) {

        toastr.options = {
            "closeButton": false,
            "debug": false,
            "positionClass": "toast-bottom-right",
            "onclick": null,
            "showDuration": "300",
            "hideDuration": "1000",
            "timeOut": "0",
            "extendedTimeOut": "0",
            "showEasing": "swing",
            "hideEasing": "linear",
            "showMethod": "fadeIn",
            "hideMethod": "fadeOut"
        }

        toastr.info(text);

    };
});

